home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / Qpopper / pop_get_subcommand.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-22  |  2.0 KB  |  62 lines

  1. /*
  2.  * Copyright (c) 1989 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef lint
  8. static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
  9. static char SccsId[] = "@(#)@(#)pop_get_subcommand.c    2.1  2.1 3/18/91";
  10. #endif /* not lint */
  11.  
  12. #include <stdio.h>
  13. #include <sys/types.h>
  14. #if defined(SOLARIS2) || defined(SYSV) || defined(AIX)
  15. #include <string.h>
  16. #else
  17. #include <strings.h>
  18. #endif
  19. #include "popper.h"
  20.  
  21. /* 
  22.  *  get_subcommand: Extract a POP XTND subcommand from a client input line
  23.  */
  24.  
  25. static xtnd_table subcommands[] = {
  26.         "xmit",     0,  0,  pop_xmit,
  27.     "xlst",        1,  2,  pop_xlst,
  28.         NULL
  29. };
  30.  
  31. xtnd_table *pop_get_subcommand(p)
  32. POP     *   p;
  33. {
  34.     xtnd_table      *   s;
  35.  
  36.     /*  Search for the POP command in the command/state table */
  37.     for (s = subcommands; s->subcommand; s++) {
  38.  
  39.         if (strcmp(s->subcommand,p->pop_subcommand) == 0) {
  40.  
  41.             /*  Were too few parameters passed to the subcommand? */
  42.             if ((p->parm_count-1) < s->min_parms)
  43.                 return((xtnd_table *)pop_msg(p,POP_FAILURE,
  44.                     "Too few arguments for the %s %s command.",
  45.                         p->pop_command,p->pop_subcommand));
  46.  
  47.             /*  Were too many parameters passed to the subcommand? */
  48.             if ((p->parm_count-1) > s->max_parms)
  49.                 return((xtnd_table *)pop_msg(p,POP_FAILURE,
  50.                     "Too many arguments for the %s %s command.",
  51.                         p->pop_command,p->pop_subcommand));
  52.  
  53.             /*  Return a pointer to the entry for this subcommand 
  54.                 in the XTND command table */
  55.             return (s);
  56.         }
  57.     }
  58.     /*  The client subcommand was not located in the XTND command table */
  59.     return((xtnd_table *)pop_msg(p,POP_FAILURE,
  60.         "Unknown command: \"%s %s\".",p->pop_command,p->pop_subcommand));
  61. }
  62.